Ext.onReady(function() {
    var userLoginPanel = Ext.create('Ext.panel.Panel', {
        bodyCls: 'bgImage',
        border : false,
        layout:"fit",
        defaults:{
            margin:'100 0 0 0'
        },
        items:{
            xtype : 'tabpanel',
            id : 'loginTabs',
            border : false,
            items:[{
                title : "身份认证",
                iconCls:'login',
                xtype : 'form',
                height:150,
                id : 'loginForm',
                defaults : {
                    margin: '20 0 0 60'
                },
                url:"doLogin",
                defaultType : 'textfield',
                labelWidth : 40,
                items: [{
                    fieldLabel: '用户名',
                    cls : 'user',
                    name: 'username',
                    labelAlign:'right',
                    labelWidth:50,
                    maxLength : 30,
                    emptyText:'请在这里填写用户名',
                    maxLengthText : '账号的最大长度为30个字符',
                    blankText:"用户名不能为空，请填写！",
                    allowBlank: false
                },{
                    fieldLabel: '密　码',
                    cls : 'key',
                    name: 'password',
                    inputType:"password",
                    labelWidth:50,
                    labelAlign:'right',
                    emptyText:'请在这里填写密码',
                    maxLengthText :'密码长度不能超过20',
                    maxLength : 20,
                    blankText:"密码不能为空，请填写！",
                    allowBlank: false,
                    enableKeyEvents:true,
                    listeners:{
                        keyup:function(t,e,eOpts){
                            if(e.keyCode == 13){
                                t.up('form').down("button").getForm().reset();
                            }
                        }
                    }
                }],
                buttons:[{
                    text:"重置",
                    handler:function(){
                        this.up('form').getForm().reset();
                    }
                },{
                    text:"登录",
                    formBind: true,
                    disabled: true,
                    handler: function() {
                        var form = this.up('form').getForm();
                        if (form.isValid()) {
                            form.submit({
                                waitMsg:"正在登录，请稍等...",
                                success: function(form, action) {
                                    var obj = Ext.util.JSON.decode(action.response.responseText);
                                    var success = obj.success;
                                    var msg = obj.msg;

                                    if (success == "true"){
                                        window.location = "/adminManager";
                                    }else{
                                        Ext.Msg.alert({title:"登录失败",message:msg,icon:Ext.MessageBox.ERROR});
                                    }
                                },
                                failure: function(form, action) {
                                    Ext.Msg.alert({title:"登录异常",message:"登录异常",icon:Ext.MessageBox.ERROR});
                                }
                            });
                        }
                    }
                }]
            },{
                title:'关于',
                xtype:'panel',
                height:300,
                iconCls:'login_about',
                layout:{
                    type:'vbox',
                    padding:'10',
                    align:'left'
                },
                id:'aboutPanel',
                defaultType : 'label',
                defaults:{
                    margin: '10 0 0 10',
                    align:'left'
                },
                items:[
                    {text:'专注于中小型企业开发，有需要的朋友可以联系我'},
                    {text:'Q Q :154341736'},
                    {text:'TEL :18589024202'}
                ]
            }]
        }
    });

    Ext.create('Ext.window.Window', {
        width : 360,
        height:290,
        maximizable : false,
        draggable : false,
        closable : false,
        resizable : false,
        items: userLoginPanel
    }).show();
});